#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> luckyNumbers(vector<vector<int>>& matrix) {
        vector<int> vv;
        for (int i = 0; i < matrix.size(); ++i)
        {
            vector<int> v1;
            v1.push_back(0);
            for (int j = 1; j < matrix[i].size(); ++j)
            {
                if (matrix[i][j] < matrix[i][v1[0]])
                {
                    v1[0] = j;
                }
            }

            for (int q = 0; q < matrix.size(); ++q)
            {
                if (matrix[q][v1[0]] > matrix[i][v1[0]])
                {
                    break;
                }
                if (q == matrix.size() - 1)
                {
                    vv.push_back(matrix[i][v1[0]]);
                }
            }
        }

        return vv;
    }
};